/**
 * Copyright (c) 2009 Collaborative Development Group, C.S. Dept., University of Bari
 *
 * All rights reserved. This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0  which accompanies this distribution, and is 
 * available at http://www.eclipse.org/legal/epl-v10.html
 */
package it.uniba.di.cdg.penelope.presenterfirst;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;

/**
 * Utility base class for injected tests.
 * <br/>
 * <strong>Deprecated:</strong> use {@link InjectedTestsRunner} instead.
 */
@Deprecated 
public abstract class AbstractInjectedTests {
	
	private Injector injector = null;

	@Before
	public void createInjector() {
		List<Module> modules = new ArrayList<Module>();
		
		provideConfigs( modules );
		
		injector = Guice.createInjector( modules );
		injector.injectMembers( this );
	}

	/**
	 * Defines the modules to be used to configure the injector for a test fixture.
	 * @param modules a list of modules where to put additional modules.
	 */
	protected abstract void provideConfigs( List<Module> modules );

	protected <T> T getInstance( Class<T> type ) {
		return injector.getInstance( type );
	}

	
	/**
	 * @return the injector
	 */
	protected Injector getInjector() {
		return injector;
	}
}
